/* 
 * $Id$
 *
 * UMKC Robotics 2009
**/

#ifndef IOBASE_H
#define IOBASE_H

#include "err.h"
#define E_NO_WRITE_CALLBACK 10
#define E_NO_READ_CALLBACK 11

#include "intdefs.h"
#include <stdio.h>


#define DEV_MAX 10
#define DEV_ALL 0
#define BSTDIN 1
#define BSTDOUT 2
#define BSTDERR 3
#define BLCD 4

typedef enum {

  Bstring=0,
  Buchar,
  Bchar,
  Bint8,
  Buint8

#ifdef WITH_INT16
  ,Buint16,
  Bint16
#endif

#ifdef WITH_INT32
  ,Buint32,
  Bint32
#endif

} IOType;

typedef union {

  signed char* str; 	
  MemByte mb;  
  int8_t i8;		
  uint8_t ui8;   	

#ifdef WITH_INT16
  int16_t i16;
  uint16_t ui16;
#endif

#ifdef WITH_INT32
  int32_t i32;
  uint32_t ui32;
#endif
  
} IOBuf;


typedef struct bot_dev {

/* order is important for initialization */
#if defined(WITH_AVRLIBC)
  FILE dev;
#else
  FILE* dev;
#endif
  int (*init)();
  int (*reset)();
  int (*destroy)();
#if defined(WITH_AVRLIBC)
  int (*read)(FILE*); 
  int (*write)(char, FILE*);
#else
  int (*read)(); 
  int (*write)();
#endif

} BotDevice;


#endif
